home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / bash_114.zip / bash-1.14.2 / support / mksysdefs < prev    next >
Encoding:
Text File  |  1994-08-13  |  11.5 KB  |  475 lines

  1. #!/bin/sh
  2. #
  3. # This file creates a file called "sysdefs.h" which contains CPP defines
  4. # helping to describe the operating system features.  We just take guesses
  5. # by looking at random files.
  6.  
  7. # Removes any inherited definitions.
  8. SYSDEF=
  9. MAKE_ANSI=
  10.  
  11. while [ $# -gt 0 ]; do
  12.     case "$1" in
  13.     -s)    shift; srcdir=$1; shift ;;
  14.     -i)    shift; incdir="$1"; shift ;;
  15.     -A)    shift; MAKE_ANSI=true ;;
  16.     *)    break ;;
  17.     esac
  18. done
  19.  
  20. if [ -n "$1" ]; then
  21.   sysdefs=$1
  22. else
  23.   sysdefs=./sysdefs.h
  24. fi
  25.  
  26. if [ -z "$srcdir" ]; then
  27.     srcdir=.
  28. fi
  29.  
  30. rm -f $sysdefs
  31.  
  32. echo "/* sysdefs.h -- #defines for your system created by $0."       >>$sysdefs
  33. echo "   Do NOT EDIT this file, since any changes will disappear." >>$sysdefs
  34. echo "   Instead, edit $0, or config.h, or machines.h. */"       >>$sysdefs
  35. echo ""                                   >>$sysdefs
  36. echo "#if !defined (_SYSDEFS_H_)"                   >>$sysdefs
  37. echo "#  define _SYSDEFS_H_"                       >>$sysdefs
  38.  
  39. # was if [ -f /usr/bin/uname ] || [ -f /bin/uname ]
  40. if ( uname >/dev/null 2>&1 ) 2>/dev/null
  41. then
  42.     UNAME=`uname`
  43.     UNAME_R=`uname -r 2>/dev/null`
  44.     UNAME_M=`uname -m 2>/dev/null`
  45.     UNAME_V=`uname -v 2>/dev/null`
  46.     UNAME_S=`uname -s 2>/dev/null`
  47.     RELEASE=`expr "$UNAME_R" : '[^0-9]*\([0-9]*\)'`
  48.     RELEASE=`expr "$RELEASE" + 0`
  49.     LEVEL=`expr "$UNAME_R" : '[^0-9]*[0-9]*.\([0-9]*\)'`
  50. fi
  51.  
  52. # check for versions of SunOS 
  53. case "${UNAME}${RELEASE}" in
  54. SunOS4*) SYSDEF=SunOS4 ;;
  55. SunOS5*) SYSDEF=SunOS5 ;;
  56. esac
  57.  
  58. # Test for NeXT
  59. if [ -d /NextLibrary ]; then
  60.     MAKE_ANSI=true
  61. fi
  62.  
  63. # Intel Paragon
  64. case "$UNAME_M" in
  65. paragon) MAKE_ANSI=true ;;
  66. esac
  67.  
  68. # Test for shared libraries (this is pretty sVr4ish).
  69. if [ -f /usr/ccs/lib/libc.so ]; then
  70.   SYSDEF=USGr4
  71. fi
  72.  
  73. # Some versions of i386 SVR4.2 make `uname' equivalent to `uname -n', which
  74. # is contrary to all other versions of uname
  75. if [ -n "$UNAME" ] && [ "$UNAME_S" != "$UNAME" ] && [ "$UNAME_S" = UNIX_SV ]; then
  76.     UNAME=UNIX_SV
  77. fi
  78.  
  79. # another check for SVR4 on 386 or 486 machines
  80. case "${UNAME_M}:${UNAME}:${UNAME_R}" in
  81. i[34]86:UNIX_SV:4.*)    SYSDEF=USGr4 ;;
  82. esac
  83.  
  84. # A check for Mips RISCos
  85. case "$UNAME_V" in
  86. UMIPS|RISCos) SYSDEF=RISCos_${RELEASE}_${LEVEL} ;;
  87. esac
  88.  
  89. # Look for an error message when trying to exec bison.  If we find
  90. # what we're looking for, then we don't have it.  If we get something
  91. # else (like an error message about no grammar file), then we have
  92. # it.
  93. HAVE_BISON=
  94. if ( cd /tmp ; bison /dev/null 2>&1 >/dev/null | grep 'no input grammar' >/dev/null 2>&1 ) 2>/dev/null
  95. then
  96.   HAVE_BISON=yes
  97. fi
  98.  
  99. # Try to locate ranlib.  I think this is a bad idea.
  100. if [ -f /usr/bin/ranlib ]; then
  101.     RANLIB_LOCATION=/usr/bin/ranlib;
  102. elif [ -f /bin/ranlib ]; then
  103.     RANLIB_LOCATION=/bin/ranlib;
  104. elif [ -f /usr/local/bin/ranlib ]; then
  105.     RANLIB_LOCATION=/usr/local/bin/ranlib;
  106. elif [ -f /usr/local/gnubin/ranlib ]; then
  107.     RANLIB_LOCATION=/usr/local/gnubin/ranlib;
  108. fi
  109.  
  110. if [ -n "${RANLIB_LOCATION}" ]; then
  111.   echo ""                        >>$sysdefs
  112.   echo "#if !defined (RANLIB_LOCATION)"         >>$sysdefs
  113.   echo "#  define RANLIB_LOCATION ${RANLIB_LOCATION}"    >>$sysdefs
  114.   echo "#endif /* RANLIB_LOCATION */"             >>$sysdefs
  115. fi
  116.  
  117. #
  118. # Is this a Xenix system?
  119. #
  120. if [ -f /xenix ]; then
  121.   SYSDEF="Xenix"
  122.   case "`/bin/uname -p`" in
  123.     *286) SYSDEF="Xenix286" ;;
  124.     *386) SYSDEF="Xenix386" ;;
  125.   esac
  126.  
  127.   # make sure that `i386' is defined for machines.h
  128.   if [ "$SYSDEF" = "Xenix386" ]; then
  129.     echo ""                >>$sysdefs
  130.     echo "#if !defined (i386)"        >>$sysdefs
  131.     echo "#  define i386"        >>$sysdefs
  132.     echo "#endif /* !i386 */"        >>$sysdefs    
  133.   fi
  134.  
  135.   # Pass the release number of the OS through to the machine descriptions
  136.   # in machines.h.
  137.   if [ -f /etc/perms/soft ]; then
  138.     rel=`grep rel= /etc/perms/soft`
  139.     case "$rel" in
  140.       *2.2.*) XREL=XENIX_22 ;;
  141.       *2.3.*) XREL=XENIX_23 ;;
  142.       *3.2.*) XREL=XENIX_32 ;;
  143.       *) XREL= ;;
  144.     esac
  145.  
  146.     if [ "$XREL" ]; then
  147.       echo ""                >>$sysdefs
  148.       echo "#if !defined ($XREL)"    >>$sysdefs
  149.       echo "#  define $XREL"        >>$sysdefs
  150.       echo "#endif /* !$XREL */"    >>$sysdefs
  151.     fi
  152.   fi
  153. fi
  154.  
  155. #
  156. # Is this some kind of Sys Vish system?
  157. #
  158. if [ -f /unix ]; then
  159.   if [ -d /generic ]; then   # This is an AIX system.
  160.     SYSDEF="aixpc"
  161.     MAKE_ANSI=true
  162.   elif [ -d /etc/conf/kconfig.d ] && [ -f /usr/include/sys/limits.h ]; then
  163.     SYSDEF="isc386"            # This is a 386 running ISC?
  164.   elif [ -f /etc/xlc.cfg ]; then
  165.     if fgrep _IBMR2 /etc/xlc.cfg >/dev/null 2>&1; then
  166.       SYSDEF=RISC6000
  167.       MAKE_ANSI=true
  168.     fi
  169.   elif [ -f /bin/4d -a -f /bin/uname ]; then
  170.     case "$UNAME_R" in
  171.       3.*) SYSDEF="Irix3" ;;
  172.       4.*) SYSDEF="Irix4" ;;
  173.       5.*) SYSDEF="Irix5" ;;
  174.       *)   SYSDEF="Irix3" ;;
  175.     esac
  176.   elif [ -d /usr/amiga ]; then
  177.     SYSDEF="amiga"        # An Amiga running V.4.
  178.   elif [ -f /bin/fxc.info ]; then
  179.     SYSDEF="alliant"
  180.   fi
  181. fi
  182.  
  183. # Is this a Unicos system?
  184. if [ -f /unicos ]; then
  185.    MAKE_ANSI=true
  186.    UnicosMachine=
  187.  
  188.    # Test for the variaous flavors of Cray machines.
  189.    if [ -x /bin/cray1 ] && /bin/cray1 2>/dev/null; then
  190.       UnicosMachine=Cray1
  191.    fi
  192.  
  193.    if [ -x /bin/cray2 ] && /bin/cray2 2>/dev/null; then
  194.       UnicosMachine=Cray2
  195.    fi
  196.  
  197.    if [ -x /bin/crayxmp ] && /bin/crayxmp 2>/dev/null; then
  198.       UnicosMachine=CrayXMP
  199.    fi
  200.    if [ -x /bin/crayymp ] && /bin/crayymp 2>/dev/null; then
  201.       UnicosMachine=CrayYMP
  202.    fi
  203.  
  204.    if [ "$UnicosMachine" ]; then
  205.       echo "#if !defined ($UnicosMachine)"    >>$sysdefs
  206.       echo "#  define $UnicosMachine"        >>$sysdefs
  207.       echo "#endif /* !$UnicosMachine */"    >>$sysdefs
  208.    fi
  209. fi
  210.  
  211. # Is this (and what kind of) a HPUX system?
  212. if [ -f /hp-ux ]; then
  213.   SYSDEF=HPUX_${RELEASE}
  214.   if [ "$RELEASE" = 6 -a "$LEVEL" -lt 2 ]; then
  215.     SYSDEF=HPUX_USG
  216.   fi
  217. fi
  218.  
  219. if [ "$SYSDEF" = "" ]; then
  220.     case "$UNAME_M" in
  221.     ESA) SYSDEF=AIXESA ;;    
  222.     XD88*) SYSDEF=XD88 ;;
  223.     M88100) SYSDEF=M88100 ;;    # Motorola Delta 88K
  224.     esac
  225. fi
  226.  
  227. # What release of SCO Unix is this?
  228. if [ "$SYSDEF" = "" -a -f /bin/uname ]; then
  229.   case `/bin/uname -X 2>/dev/null | grep '^Release' 2>/dev/null` in
  230.     *3.2v4.*) SCOREL=SCOv4 ;;
  231.        *) SCOREL= ;;
  232.   esac
  233.  
  234.   if [ "$SCOREL" ]; then
  235.     echo ""                    >>$sysdefs
  236.     echo "#if !defined ($SCOREL)"        >>$sysdefs
  237.     echo "#  define $SCOREL"            >>$sysdefs
  238.     echo "#endif /* !$SCOREL */"        >>$sysdefs
  239.   fi
  240. fi
  241.  
  242. #
  243. # Default to cadmus for unknown SysVish systems
  244. #
  245. if [ -f /unix ] && [ "$SYSDEF" = "" ]; then
  246.   SYSDEF="cadmus"
  247. fi
  248.  
  249. if [ "$SYSDEF" != "" ]; then
  250.   echo ""                    >>$sysdefs
  251.   echo "#if !defined ($SYSDEF)"            >>$sysdefs
  252.   echo "#  define $SYSDEF"            >>$sysdefs
  253.   echo "#endif /* $SYSDEF */"            >>$sysdefs
  254. fi
  255.  
  256. # Now look for certain include files in a list of directories
  257. # Poor substitute for autoconf
  258.  
  259. # Add any other directories where include files are found to this list or
  260. # create another case
  261. if [ -n "$incdir" ]; then
  262.     dirlist="$incdir"
  263. else
  264.     case "$SYSDEF" in
  265.     RISCos*) dirlist="/bsd43/usr/include";;
  266.     *) dirlist="/usr/include /usr/include/bsd /usr/include/ansi" ;;
  267.     esac
  268. fi
  269.  
  270. # Code fragment to be executed to find a particular include file.  Make sure
  271. # to set `file' to the pathname of the file you want, relative to /usr/include,
  272. # before calling `eval $findf'.
  273. findf="
  274. found='';
  275. for d in \$dirlist;
  276. do
  277.     if test -f \$d/\$file;
  278.     then
  279.         found=yes;
  280.         break;
  281.     fi;
  282. done
  283. "
  284.  
  285. found=
  286. file=sys/stream.h
  287. eval $findf
  288. if [ -n "$found" ]; then
  289.   echo ""                    >>$sysdefs
  290.   echo "#if !defined (HAVE_SYS_STREAM_H)"    >>$sysdefs
  291.   echo "#  define HAVE_SYS_STREAM_H"        >>$sysdefs
  292.   echo "#endif /* HAVE_SYS_STREAM_H */"        >>$sysdefs
  293. fi
  294.  
  295. found=
  296. file=sys/ptem.h
  297. eval $findf
  298. if [ -n "$found" ]; then
  299.   echo ""                    >>$sysdefs
  300.   echo "#if !defined (HAVE_SYS_PTEM_H)"        >>$sysdefs
  301.   echo "#  define HAVE_SYS_PTEM_H"        >>$sysdefs
  302.   echo "#endif /* HAVE_SYS_PTEM_H */"        >>$sysdefs
  303. fi
  304.  
  305. file=sys/pte.h
  306. eval $findf
  307. if [ -n "$found" ]; then
  308.   echo ""                    >>$sysdefs
  309.   echo "#if !defined (HAVE_SYS_PTE_H)"        >>$sysdefs
  310.   echo "#  define HAVE_SYS_PTE_H"        >>$sysdefs
  311.   echo "#endif /* HAVE_SYS_PTE_H */"        >>$sysdefs
  312. fi
  313.  
  314. file=sys/wait.h
  315. eval $findf
  316. if [ -n "$found" ]; then
  317.   echo ""                    >>$sysdefs
  318.   echo "#if !defined (HAVE_WAIT_H)"        >>$sysdefs
  319.   echo "#  define HAVE_WAIT_H"            >>$sysdefs
  320.   echo "#endif /* HAVE_WAIT_H */"        >>$sysdefs
  321. fi
  322.  
  323. file=sys/resource.h
  324. eval $findf
  325. if [ -n "$found" ]; then
  326.   echo ""                    >>$sysdefs
  327.   echo "#if !defined (HAVE_RESOURCE)"        >>$sysdefs
  328.   echo "#  define HAVE_RESOURCE"        >>$sysdefs
  329.   echo "#endif /* HAVE_RESOURCE */"        >>$sysdefs
  330. fi
  331.  
  332. file=sys/param.h
  333. eval $findf
  334. if [ -n "$found" ]; then
  335.   echo ""                    >>$sysdefs
  336.   echo "#if !defined (HAVE_SYS_PARAM)"        >>$sysdefs
  337.   echo "#  define HAVE_SYS_PARAM"        >>$sysdefs
  338.   echo "#endif /* HAVE_SYS_PARAM */"        >>$sysdefs
  339. fi
  340.  
  341. file=unistd.h
  342. eval $findf
  343. if [ -n "$found" ]; then
  344.   echo ""                    >>$sysdefs
  345.   echo "#if !defined (HAVE_UNISTD_H)"        >>$sysdefs
  346.   echo "#  define HAVE_UNISTD_H"        >>$sysdefs
  347.   echo "#endif /* HAVE_UNISTD_H */"        >>$sysdefs
  348. fi
  349.  
  350. file=stdlib.h
  351. eval $findf
  352. if [ -n "$found" ]; then
  353.   echo ""                    >>$sysdefs
  354.   echo "#if !defined (HAVE_STDLIB_H)"        >>$sysdefs
  355.   echo "#  define HAVE_STDLIB_H"        >>$sysdefs
  356.   echo "#endif /* HAVE_STDLIB_H */"        >>$sysdefs
  357. fi
  358.  
  359. file=limits.h
  360. eval $findf
  361. if [ -n "$found" ]; then
  362.   echo ""                    >>$sysdefs
  363.   echo "#if !defined (HAVE_LIMITS_H)"        >>$sysdefs
  364.   echo "#  define HAVE_LIMITS_H"        >>$sysdefs
  365.   echo "#endif /* HAVE_LIMITS_H */"        >>$sysdefs
  366. fi
  367.  
  368. file=alloca.h
  369. eval $findf
  370. if [ -f /usr/include/alloca.h ]; then
  371.   echo ""                    >>$sysdefs
  372.   echo "#if !defined (HAVE_ALLOCA_H)"        >>$sysdefs
  373.   echo "#  define HAVE_ALLOCA_H"        >>$sysdefs
  374.   echo "#endif /* HAVE_ALLOCA_H */"        >>$sysdefs
  375. fi
  376.  
  377. file=dirent.h
  378. eval $findf
  379. if [ -n "$found" ]; then
  380.   echo ""                    >>$sysdefs
  381.   echo "#if !defined (HAVE_DIRENT_H)"        >>$sysdefs
  382.   echo "#  define HAVE_DIRENT_H"        >>$sysdefs
  383.   echo "#endif /* HAVE_DIRENT_H */"        >>$sysdefs
  384. fi
  385.  
  386. file=string.h
  387. eval $findf
  388. if [ -n "$found" ]; then
  389.   echo ""                    >>$sysdefs
  390.   echo "#if !defined (HAVE_STRING_H)"        >>$sysdefs
  391.   echo "#  define HAVE_STRING_H"        >>$sysdefs
  392.   echo "#endif /* HAVE_STRING_H */"        >>$sysdefs
  393. fi
  394.  
  395. file=varargs.h
  396. eval $findf
  397. if [ -n "$found" ]; then
  398.   echo ""                    >>$sysdefs
  399.   echo "#if !defined (HAVE_VARARGS_H)"        >>$sysdefs
  400.   echo "#  define HAVE_VARARGS_H"        >>$sysdefs
  401.   echo "#endif /* HAVE_VARARGS_H */"        >>$sysdefs
  402. fi
  403.  
  404. # Does the system have a /dev/fd directory?
  405. if [ -d /dev/fd ]; then
  406.   echo ""                    >>$sysdefs
  407.   echo "#if !defined (HAVE_DEV_FD)"        >>$sysdefs
  408.   echo "#  define HAVE_DEV_FD"            >>$sysdefs
  409.   echo "#endif /* HAVE_DEV_FD */"        >>$sysdefs
  410. fi
  411.  
  412. # Is this SVR4.2?  It's subtly different from USGr4
  413. if [ "$UNAME" = "UNIX_SV" ] && [ "$UNAME_R" = "4.2" ]; then
  414.   echo ""                    >>$sysdefs
  415.   echo "#if !defined (USGr4_2)"        >>$sysdefs
  416.   echo "#  define USGr4_2"        >>$sysdefs
  417.   echo "#endif /* USGr4_2 */"        >>$sysdefs
  418. fi
  419.  
  420. # Is this AIX PS/2 1.3?  Yuck.
  421. if [ "$UNAME" = "AIX" ] && [ "$UNAME_V" = "1" ] && [ "$RELEASE" = "3" ]; then
  422.   case "$UNAME_M" in
  423.   i386|i486)
  424.     echo ""                    >>$sysdefs
  425.     echo "#if !defined (AIX_13)"        >>$sysdefs
  426.     echo "#  define AIX_13"            >>$sysdefs
  427.     echo "#endif /* AIX_13 */"        >>$sysdefs
  428.     ;;
  429.   esac
  430. fi
  431.  
  432. if [ -n "$HAVE_BISON" ]; then
  433.   echo ""                    >>$sysdefs
  434.   echo "#if !defined (HAVE_BISON)"        >>$sysdefs
  435.   echo "#  define HAVE_BISON"            >>$sysdefs
  436.   echo "#endif /* HAVE_BISON */"        >>$sysdefs
  437. fi
  438.  
  439. # Functions to test for a la autoconf
  440. #    getwd
  441. #    getcwd
  442. #    strchr
  443. #    strcasecmp
  444. #    getgroups
  445. #    setlinebuf
  446. #    strerror
  447. #    vfprintf
  448. #    bcopy
  449. #    getdtablesize
  450. #    setdtablesize
  451. #    alloca
  452. #    gethostname
  453. #    memmove (missing)
  454. #    mkfifo (missing)
  455. #
  456. # Other things to test
  457. #    opendir robustness
  458. #    dup2 working
  459. #    void sighandler
  460. #    sys_siglist[]
  461. #    uid_t, gid_t
  462. #    have_getpw_decls
  463. #    reversed setvbuf args
  464. #    int getgroups
  465.  
  466. # If this system's cpp might not like `/**/#' in cpp-Makefile, make an
  467. # alternate ansi-style cpp-Makefile.
  468. if [ -n "$MAKE_ANSI" ]; then
  469.    grep -v '/\*\*/' ${srcdir}/cpp-Makefile >ansi-Makefile
  470. fi
  471.  
  472. # These should be the last 2 lines in this file!
  473. echo ""                        >>$sysdefs
  474. echo "#endif /* _SYSDEFS_H_ */"            >>$sysdefs
  475.